//
//  WGTableViewDataSource.m
//  NiuWaJiaoYu
//
//  Created by MinLison on 2017/11/7.
//  Copyright © 2017年 niuwaketang. All rights reserved.
//

#import "BaseTableViewDataSource.h"

@interface BaseTableViewDataSource()
@property(nonatomic, weak) id<QMUITableViewDataSource> dataSourceProxy;
@end

@implementation BaseTableViewDataSource
- (instancetype)init
{
        return [self initWithReceiver:nil];
}
- (instancetype)initWithReceiver:(nullable id<QMUITableViewDataSource>)receiver
{
        if (self = [super init])
        {
                self.dataSourceProxy = receiver;
        }
        return self;
}
#pragma mark - <QMUITableViewDelegate, QMUITableViewDataSource>

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        if ([self.dataSourceProxy respondsToSelector:_cmd]) {
                return [self.dataSourceProxy numberOfSectionsInTableView:tableView];
        }
        return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        if ([self.dataSourceProxy respondsToSelector:_cmd]) {
                return [self.dataSourceProxy tableView:tableView numberOfRowsInSection:section];
        }
        return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        if ([self.dataSourceProxy respondsToSelector:_cmd]) {
                return [self.dataSourceProxy tableView:tableView cellForRowAtIndexPath:indexPath];
        }
        return nil;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
        NSLog(@"aa");
        return nil;
}
@end
